package BizLogic;


import java.sql.SQLException;
import java.util.ArrayList;

import model.LoginCredentials;
import model.Staff;
import dao.BookingDAO;
import dao.DAOFactory;
import dao.LoginCredentialsDAO;

import dao.StaffDAO;

public class StaffManager {
private StaffDAO StaffDAO;

	
	public StaffManager(){
		
		StaffDAO = DAOFactory.loadInstance().getStaffDAO();
	}
	public String getEmail(String staffID)
	{
		String email="";
		try {
			email=StaffDAO.searchEmail(staffID);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return email;
	}
	public ArrayList<Staff> getAll()
	{
		ArrayList<Staff> s=null;
		try {
			s = StaffDAO.findAllStaff();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return s;
	}
	public void addRecord(Staff s,LoginCredentials lc)
	{
		try {
			
			StaffDAO.insertStaff(s);
			new LoginCredentialsManager().addRecord(lc);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		
	}
	public void updateRecord(Staff s,LoginCredentials lc){
		
		try {
			StaffDAO.updateStaff(s);
			new LoginCredentialsManager().updateRecord(lc.getStaffID(), lc.getRole());
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
	}
	public ArrayList<Staff> searchStaff(String staffName){//NEW 
		
		try {
			return StaffDAO.SearchStaff(staffName);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
		
	}
	}
